Remove submodule directory before cloning
authorAlex Crichton <alex@alexcrichton.com>
Thu, 14 Apr 2016 17:40:36 +0000 (10:40 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 14 Apr 2016 17:40:36 +0000 (10:40 -0700)
If the directory is in a corrupt state that caused an existing repository to not
successfully open, then we'll want to blow it away anything that already exists
to ensure we start from a clean slate.

Closes #2567

src/cargo/sources/git/utils.rs

index d865262d080c28c99aa74dd86075b5f337e6668c..74ae03398dceb9b7345f056d9ff94d61635a7059 100644 (file)
@@ -339,6 +339,7 @@ impl<'a> GitCheckout<'a> {
                     }
                     Err(..) => {
                         let path = repo.workdir().unwrap().join(child.path());
+                        let _ = fs::remove_dir_all(&path);
                         try!(git2::Repository::clone(url, &path))
                     }
                 };